﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ATM
{
    public class TransferAccounts : Transaction
    {
        public String account;
        public String targetAccount;
        public Decimal amount;

        public TransferAccounts()
        {
            this.account = "";
            this.targetAccount = "";
            this.amount = 0;
        }

        public void transferAccount(BankDatabase bankDatabase)
        {
            for (int i = 0; i < bankDatabase.bankAccounts.Count; i++)
            {
                if (bankDatabase.bankAccounts[i].getID() == this.account)
                {
                    bankDatabase.bankAccounts[i].decreaseAmount(this.amount);
                }
            }

            for (int i = 0; i < bankDatabase.bankAccounts.Count; i++)
            {
                if (bankDatabase.bankAccounts[i].getID() == this.targetAccount)
                {
                    bankDatabase.bankAccounts[i].increaseAmount(this.amount);
                }
            }
        }
    }
}
